package com.recyclerviewdemo.adapters;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.recyclerviewdemo.Fragment.AndroidFragment;
import com.recyclerviewdemo.Fragment.FuLiFragment;
import com.recyclerviewdemo.Fragment.TabFragment;
import com.recyclerviewdemo.R;
import com.trello.rxlifecycle.components.RxFragment;

/**
 * Created by Yang on 2016/9/5.
 */
public class MyPageAdapter extends FragmentPagerAdapter {
    private Context mContext;

    public MyPageAdapter(FragmentManager fm, Context context) {
        super(fm);
        mContext = context;
    }

    @Override
    public Fragment getItem(int position) {

        Fragment result = new FuLiFragment();

        switch (position){
            case 0:
                result = new FuLiFragment();
                break;
            case 1:
                result = new AndroidFragment();
                break;
            case 2:
                result = new FuLiFragment();
                break;
        }

        return result;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        String title = mContext.getString(R.string.no_title);
        switch (position) {
            case 0:
                title = mContext.getString(R.string.item1);
                break;
            case 1:
                title = mContext.getString(R.string.item2);
                break;
            case 2:
                title = mContext.getString(R.string.item3);
                break;
        }
        return title;
    }
}
